package com.example.shixunandjavagotoyangchen.Activity;

import com.example.modelviewpresenter.Model.BasterModel;
import com.example.shixunandjavagotoyangchen.Sunshine.Okhttp.BasterOkhttp;

import java.util.List;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

public class FoodModel extends BasterModel implements FoodContion.aainmodel {


    @Override
    public void getinmodel(FoodCallback foodCallback) {
        BasterOkhttp.getBasterOkhttp().getRetrofit().create(Api.class).getfood()
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.computation())
                .subscribe(new Observer<FoodJavaBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {
                    }

                    @Override
                    public void onNext(FoodJavaBean foodJavaBean) {
                        List<FoodJavaBean.DataBean> dataBeans = foodJavaBean.getData();
                        foodCallback.sueeofers(dataBeans);
                    }

                    @Override
                    public void onError(Throwable e) {
                    }

                    @Override
                    public void onComplete() {
                    }
                });
    }

}
